<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<section class="main-view">
    <div class="main-view-content">
        <div class="flex" id="myIDs">
            <div class="flex-container">
                <h1 class="network-name" title="{{businessNetworkName}}">My IDs for {{businessNetworkName}}</h1>
                <button id="issueID" type="button" class="secondary" (click)="issueNewId()">
                    <span>Issue New ID</span>
                </button>
            </div>

            <div class="identity-title">
                <div class="selected-border"></div>
                <div class="id">ID Name</div>
                <div class="status">Status</div>
            </div>
            <div class="identity" *ngFor="let ID of myIDs" (dblclick)="setCurrentIdentity(ID, true)">
                <div class="selected-border"
                     [ngClass]="{'selected-border--selected': ID.ref === currentIdentity}"></div>
                <div class="id">
                    {{identityCards.get(ID.ref).getUserName()}}
                </div>
                <div class="flex" *ngIf="ID.ref===currentIdentity">
                    In Use
                </div>
                <div class="flex" *ngIf="ID.ref!==currentIdentity && ID.usable ">
                    <i>In my wallet</i>
                </div>
                <div class="flex" *ngIf="ID.ref!==currentIdentity && !ID.usable">
                    <i>Bound participant not found</i>
                </div>
                <div class="actions" *ngIf="ID.ref!==currentIdentity">
                    <button class="clear" *ngIf="ID.usable" (click)="setCurrentIdentity(ID, true)">Use now</button>
                    <button class="clear" (click)="openRemoveModal(ID.ref); $event.stopPropagation()">Remove</button>
                </div>
            </div>
        </div>
        <div class="flex" id="allIDs">
            <div class="flex-container">
                <h1 class="network-name" title="{{businessNetworkName}}">All IDs for {{ businessNetworkName }}</h1>
            </div>

            <div class="identity-title">
                <div class="selected-border"></div>
                <div class="id cell-24">ID Name</div>
                <div class="issued-to cell-24">Issued to</div>
                <div class="status cell-24">Status</div>
                <div class="actions cell-24"></div>
            </div>
            <div class="identity" *ngFor="let id of allIdentities">
                <div class="selected-border"
                     [ngClass]="{'selected-border--selected': id.ref === currentIdentity}"></div>
                <div class="id cell-24">
                    {{ id.name }}
                </div>
                <div class="issued-to cell-24">
                    <span placement="top" container="body" ngbTooltip="{{ id.participant.$namespace }}.{{ id.participant.$type }}">{{ id.participant.$identifier }} ({{ id.participant.$type }})</span>
                </div>
                <div class="status cell-24">
                    {{ id.state }}
                </div>
                <div class="cell-24">
                    <div class="actions" *ngIf="id.ref !== currentIdentity && id.state!=='REVOKED'">
                        <button class="clear" (click)="revokeIdentity(id)">Revoke</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <app-footer></app-footer>
</section>
